package com.codeyang.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codeyang.domain.PickAddr;
import com.codeyang.service.PickAddrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 描述: TO-删除标志-DO
 *
 * @author CodeYang_Site
 * @version 2021/5/27 10:08
 */
@Api(tags = "自提点管理")
@RequestMapping("shop/pickAddr")
@RestController
public class PickAddrController {


    @Autowired
    private PickAddrService pickAddrService;


    @GetMapping("page")
    @ApiOperation("分页查询自提点")
    public ResponseEntity<Page<PickAddr>> page(Page<PickAddr> page, PickAddr pickAddr) {
        Page<PickAddr> pickAddrPage = pickAddrService.page(page, new LambdaQueryWrapper<PickAddr>()
                .like(StringUtils.hasText(pickAddr.getAddrName()), PickAddr::getAddrName, pickAddr.getAddrName())
        );
        return ResponseEntity.ok(pickAddrPage);
    }


    @PostMapping
    @ApiOperation("新增公告")
    public ResponseEntity<Void> test(@RequestBody PickAddr pickAddr) {
        pickAddrService.save(pickAddr);
        return ResponseEntity.ok().build();
    }

}
